﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Resn.WhuPub.BLL;
using System.Linq;

namespace Resn.WhuPub.WPFClientUI
{
        /// <summary>
        /// SearchCategoryWindow.xaml 的交互逻辑
        /// </summary>
        public partial class SearchCategoryWindow
        {
                private readonly GlobalManager _gm = GlobalManager.Instance;

                public SearchCategoryWindow()
                {
                        InitializeComponent();
                }

                private void Window_Loaded(object sender, RoutedEventArgs e)
                {
                        _gm.Name = string.Empty;
                        _gm.Code = string.Empty;

                        LayoutRoot.DataContext = _gm;
                }

                private void Window_OnMouseDown(object sender, MouseButtonEventArgs e)
                {
                        if (e.ChangedButton == MouseButton.Left)
                        {
                                this.DragMove();
                        }
                }

                private void AcceptButton_Click(object sender, RoutedEventArgs e)
                {
                        _gm.Name = _gm.Name.Trim();
                        _gm.Code = _gm.Code.Trim();

                        try
                        {
                                if (!string.IsNullOrEmpty(_gm.Name))
                                {
                                        //_gm.Categorys = _gm.Categorys.Where(i => i.Name.Contains(name)).ToList();
                                }

                                if (!string.IsNullOrEmpty(_gm.Code))
                                {
                                        //_gm.Categorys = _gm.Categorys.Where(i => i.Code.Contains(code)).ToList();
                                }
                        }
                        catch (Exception ex)
                        {
                                MessageBox.Show(ex.Message);
                                return;
                        }

                        finally
                        {
                        }

                        Close();

                }

                
        }
}